package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 平台后台 - 会员支付策略配置 - 支付渠道设置
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-10
 */
@Entity
@Table(schema = "public", name = "ord_platform_payment_channel", indexes = {@Index(name = "ord_platform_payment_channel_pay_type_id_idx", columnList = "pay_type_id")})
public class PlatformPaymentChannelDO implements Serializable {
    private static final long serialVersionUID = 726909321038280944L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_platform_payment_channel_seq")
    @SequenceGenerator(sequenceName = "ord_platform_payment_channel_seq", name = "ord_platform_payment_channel_seq", allocationSize = 1)
    private Long id;

    /**
     * 多对一双向支付方式
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "pay_type_id")
    private PlatformPaymentTypeDO payType;

    /**
     * 支付渠道，定义在 OrderPayChannelEnum 中
     */
    @Column
    private Integer payChannel;

    /**
     * 支付渠道名称
     */
    @Column(columnDefinition = "varchar(200)")
    private String payChannelName;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public PlatformPaymentTypeDO getPayType() {
        return payType;
    }

    public void setPayType(PlatformPaymentTypeDO payType) {
        this.payType = payType;
    }

    public Integer getPayChannel() {
        return payChannel;
    }

    public void setPayChannel(Integer payChannel) {
        this.payChannel = payChannel;
    }

    public String getPayChannelName() {
        return payChannelName;
    }

    public void setPayChannelName(String payChannelName) {
        this.payChannelName = payChannelName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        PlatformPaymentChannelDO that = (PlatformPaymentChannelDO) o;
        return id.equals(that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
